{extend name="public/base" /}
{block name="style"}
<link rel="stylesheet" href="__PUBLIC__/admin/material/css/index.css?v=20221110&times=111" />
<link rel="stylesheet" href="__PUBLIC__/admin/material/css/iconfont.css" />
{include file="material/_ali_icon" /}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/webuploader/webuploader.css">
<style>
    .main-box-body .navs .active {
        background: azure;
        color: #03a9f4;
        border: 1px solid #03a9f4;
        border-radius: 5px;
    }

    a {
        color: #777;
        text-decoration: none;
    }

    a:hover {
        text-decoration: none
    }

    .table tbody>tr>td {
        padding: 0px 8px;
    }

    .table-hover>tbody>tr:nth-child(odd) {
        background-color: #f9f9f9;
    }

    .table-responsive {
        min-height: 470px;
    }
</style>

<style>
    #sidebar-nav .nav>.open .submenu>li>.submenu a:before,
    #sidebar-nav .nav>.active .submenu>li>.submenu a:before {
        content: "";
    }
</style>
<style>
	.uploadify-button-text{
		position: relative;
		display: inline-block;
		cursor: pointer;
		background: #fff;
		padding: 0px 5px;
		color: #333;
		text-align: center;
		border-radius: 3px;
		overflow: hidden;
		border: 1px solid #ccc;
	}
	em{
		color: red;
	}
	</style>
{/block}
{block name="body"}
<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-right">
			{if checkAuthRule('del')}<button type="button" class="btn btn-warning"> <input class="checkbox check-all" type="checkbox" style="display: inline-block;margin-top: -2px;vertical-align: middle;"> 全选 </button>{/if}
			
			{if checkAuthRule('down_all')}<button type="button" class="btn btn-info"  onclick="down_all('{:url('down_all',['source' => 'index'])}')">
				<i class="fa fa-cloud-download"></i> 全库TXT 
			</button>{/if}

			<button type="button" class="btn btn-primary" id="createUrl">
				<i class="fa fa-plus"></i> 添加素材 <span class="caret"></span>
			</button>
			{if checkAuthRule('del')}<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>{/if}
		</div>
		<div class="row">
			<form method="get">
				
				{include file="material/_search2" /}
			</form>
		</div>
	</header>
	<div class="main-box-body clearfix">
		<!-- 搜索相关 -->
		{include file="material/_search" /}
		<!-- 如果是爆款文案 -->
		{include file="material/_search_hot" /}
		<div id="" class="clear"></div>
					
            {empty name="list"}
            {/empty}
            <div class="tiktok">
                <div class="row toolTip">
                {volist name="list" id="vo"}
                <div class="col-md-3">
                    <div class="panel panel-default">
                        <!-- <div class="panel-heading">
							<span style="font-size:16px;">ID:{$vo['id']} {$vo['title']}</span>
							<span>{$vo['show_time']}</span>
						</div> -->
						{php}
							$bgcolor = "#fbfafa";
							$color = "";
							if($vo["channel_zh"] == "男"){
								$bgcolor = "#dceaf7";
								$color = '#658399';
							}
							if($vo["channel_zh"] == "女"){
								$bgcolor = "#fff5ff";
								$color = '#ad8d93';
							}
						{/php}
                        <div class="panel-body" style="background: {$bgcolor};">
                            <span style="color:{$color};">{:str_replace("####","<br/>",htmlspecialchars_decode($vo['content_zh2']))}</span>
                            <div class="show">展开</div>
							<div class="rate" title="评分">{$vo.score}</div>
                        </div>
                        <div class="panel-footer" style="flex-direction: column;">
							<div style="width: 100%;justify-content: space-between;color: #b1b0b0;">
								<div style="flex:1;display: flex;width: 50%;">
									<span style="display: inline-block;max-width: 80%;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;word-break: break-all;">ID:{$vo['id']} {$vo['title']} </span>
									<span style="color: #e84e409c;margin-left: 4px;" title="量级">{$vo['magnitude_num_zh']}</span>
									<!-- <span  title="热度">{$vo.hot_zh}</span> -->
								</div>
								<span>  {$vo['show_time']}</span>
							</div>
							<div style="justify-content: space-between;width: 100%;">
								<div style="display: flex;align-items: center;">
									<input class="ids row-selected" type="checkbox" name="id[]" value="{$vo['id']}" style="margin: 0;"> &nbsp;
									<div style="display: flex;align-items: center;">
										<span class="title">{$vo.book_id_zh}</span>
										<!-- {$vo.category_id_zh} -->
										<div class="tiktokLabel">
											{$vo.tag_ids_zh}
										</div>
										
									</div>
									
								</div>
								
								<div style="font-size: 14px;display: flex;">
									<div onclick="copyContent('{:str_replace("####","<br/>",htmlspecialchars_decode($vo['content_zh2']))}', {$vo.id})" class="douyin_copy " style="color:#838383;margin-right:6px">
										复制(<span class="copyNum emCopy{$vo.id}">{$vo['copy_click_num']}</span>) 
									</div>
									{if checkAuthRule('edit')}
									<div style="cursor: pointer;margin-right:6px">
										<a style="color:#838383" onclick="editreferral(this)" data-json='{:json_encode($vo)}'>修改</a>
									</div>
									{/if}
									<div onclick="follow(this, {$vo['id']})" style="cursor: pointer;color: #f3ad9d;
									border: 1px solid #f3ad9d;
									padding: 0 4px;
									border-radius: 5px;">
										<!-- &nbsp;<i style="font-size:24px;" class="iconfont icon-tianjia2"></i> -->
										<i class="fa fa-plus"></i>
										{if $vo['is_follow']}已加{else/}加入{/if}({$vo['follow_num']}) 
									</div>
								</div>
							</div>
                        </div>
                    </div>
                    <div class="mask">
                        <i class="iconfont icon-cuowu"></i>
                        <!-- <span aria-hidden="true">×</span> -->
                        <div class="content" id="content_{$vo.id}" style="background: {$bgcolor};color:{$color}">{:str_replace("####","<br/>",htmlspecialchars_decode($vo['content_zh2']))}</div>
						<div class="panel-footer" style="flex-direction: column;font-size: 14px;">
							<div style="width: 100%;justify-content: space-between;color: #b1b0b0;">
								<span>ID:{$vo.id} </span>
								<span>{$vo.show_time} </span>
							</div>
							<div style="justify-content: space-between;width: 100%;margin-top: 3px;">
								<div style="display: flex;align-items: center;">
									<input class="ids row-selected" type="checkbox" name="id[]" value="4863" style="margin: 0;"> &nbsp;
									<div style="display: flex;align-items: center;">
										<span class="title">{$vo.book_id_zh}</span>
										<!-- - -->
										<div class="tiktokLabel">
											{$vo.tag_ids_zh}
										</div>
									</div>
								</div>
								
								<div style="font-size: 14px;display: flex;">
									<div onclick="copyContent('{:str_replace("####","<br/>",htmlspecialchars_decode($vo['content_zh2']))}', {$vo.id})" class="douyin_copy" style="color:#838383;margin-right:6px">
										复制(<span class="copyNum emCopy{$vo.id}">{$vo['copy_click_num']}</span>) 
									</div>
									{if checkAuthRule('edit')}
									<div style="cursor: pointer;margin-right:6px">
										<a style="color:#838383"  onclick="editreferral(this)" data-json='{:json_encode($vo)}'>修改</a>
									</div>
									{/if}
									<div onclick="follow(this, {$vo.id})" style="cursor: pointer;color: #f3ad9d;
									border: 1px solid #f3ad9d;
									padding: 0 4px;
									border-radius: 5px;">
										<!-- &nbsp;<i style="font-size:24px;" class="iconfont icon-tianjia2"></i> -->
										<i class="fa fa-plus" style="font-size:14px;position: inherit;"></i>
										加入
									</div>
								</div>
							</div>
                        </div>
                    </div>
                </div>
                {/volist}
                </div>
            </div>
			{$page}
	</div>
</div>

<div class="modal fade" id="create-referral-link-modal">
	<div class="modal-dialog" role="document">
	   <div class="modal-content">
		   <div class="modal-header">
			   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
			   <span style="font-size: 20px;"><span id="referralname">添加</span></span>
		   </div>
		   <div class="modal-body">
			   <div data-bind="visible: loading" class="loading-panel" style="display: none;">
				   <i class="fa fa-spin fa-spinner"></i>
			   </div>
			   <form class="form-horizontal modelform">
				   {include file="material/_from" /}
			   </form>
		   </div>
		   <div class="modal-footer">
			   <button type="button" id="createreferral" class="btn btn-primary ">提交</button>
		   </div>
	   </div>
   </div>
</div>

{include file="adsmaterialbook/_from" /}
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/plugs/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.custom.js"></script>
<script type="text/javascript">

$(function() {
	$('#createUrl').on('click',function(){
		var is_rule = '{:checkAuthRule("add")}';
		if(!is_rule){
			layer.msg("你没权限添加");
			return;
		}
		var $modal = $('#create-referral-link-modal');
		$modal.on('shown.bs.modal', function () {
			//默认选择外
			multipleInput('{:stristr($action, "inside")?3:4}'.split(','),$("input:checkbox[name=hot]"));
			$("#picker_ebook").html('<div>上传文案</div>')
			$("#picker_ebook").SentUploader({
				server:"{:url('Upload/Uploadtxt')}",
				fileNumLimit:1,
				uploadEvents: {
					uploadComplete:function(file){}
				},
				listName : 'fileList_ebook',
				hiddenName: 'field_ebook',
				hiddenValType:2,
				fileSingleSizeLimit:50*1024*1024,
				closeX:true
			},
			{
				fileType: 'service',
				filename : 'images',
			});
		});	
		$modal.modal({backdrop: 'static', keyboard: false});
	});
	$("#createreferral").on('click',function(){
		var data = $('.modelform').serializeJson();

		if ( data['book_id'] == undefined) {
			// updateAlert("书名不能为空", 'danger');
			// return false;
		}
		if (data['content'].length==0 && $("#field_ebook").val() == '') {
			updateAlert("不能为空", 'danger');
			return false;
		}
		var url = "{:url('add')}";
		$.ajax({
			type: "POST",
			url,
			data,
			dataType: "json",
			success: function(data){
				if(data.code==1){
					updateAlert(data.msg, 'success');
					setTimeout(function() {	
						window.location.reload();
					}, 100);
				}else{
					updateAlert("添加，"+data.msg, 'danger');
				}
			},
			error : function(e){
				console.log(e.status);
				console.log(e.responseText);
			}
		})
	});
});


$('.panel-body .show').click(function(){
	$(this).parent().parent().siblings().show()
})
$('.mask i').click(function(){
	$(this).parent().hide()
})
</script>
{include file="material/pub_footer"}
{/block}